<?php
    if($this->unknownError == true) {
        echo $this->view->flashMessage()->renderMessage('En ukjent feil oppstod', RedCross_View_Helper_FlashMessage::ERROR);
    }
    
    echo $this->flashMessage()->renderMessages(); 
?>

<?php 
    $this->pageHeader('Rediger område');
?>

<h1>Rediger område: <?php echo $this->access->area; ?></h1>

<?php
$this->editForm->setMethod('post');
$this->editForm->setAction($this->url());
echo $this->editForm;
?>

<div class="header_wrapper">
    <h1>Medlemmer</h1>
    <?php echo $this->filterForm; ?>
</div>

<form id="edit_room_access_to_members" method="post" action="<?php echo $this->url(array('module' => 'admin', 'controller' => 'access', 'action' => 'edit_members'), null, false); ?>">


<table id="roomaccess_members">
    <thead>
        <tr>
            <th>&nbsp;</th>
            <th>Navn</th>
        </tr>
    </thead>
    <tbody>
    <?php foreach ($this->members as $member): ?>
    <?php
    $accessInfo = null;
    foreach ($member->MemberAccess as $memberAccess):
        if ($memberAccess->access_id == $this->access->id):
            $accessInfo = $memberAccess;
        endif;
    endforeach;
    ?>
    <tr>
        <td class="checkbox"><input type="checkbox" id="member_<?php echo $member->id; ?>" name="members[]" value="<?php echo $member->id ?>" /></td>
        <td><label for="member_<?php echo $member->id; ?>"><?php echo $this->escape($member->first_name . ' ' . $member->last_name); ?></label></td>
    </tr>
    <?php endforeach; ?>
    </tbody>
</table>

<?php
    $filter = $this->filterForm ->getValue('filter');
    if ($filter === "no_access"):?>
        <p class="clear">&nbsp;</p>
        <input type="hidden" value="add_members_to_access" name="action" />
        <input type="submit" value="Legg til valgte" name="submit" class="positive" />
<?php else:?>
        <p class="clear">&nbsp;</p>
        <input type="hidden" value="remove_members_from_access" name="action" />
        <input type="submit" value="Fjern valgte" name="submit" class="negative" />
<?php endif?>
</form>

<p>&nbsp;</p>
<p><strong>Adgangslistene er ikke garantert oppdatert eller fullstendige.</strong></p>&nbsp;
